﻿<Page
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:yaTDL="clr-namespace:yaTDL"
      xmlns:yaTDL_Core_Converters="clr-namespace:yaTDL.Core.Converters;assembly=yaTDL.Core"       
       
      xmlns:yaTDL_Controls="clr-namespace:yaTDL.Controls" x:Class="yaTDL.SettingsPage" 
      mc:Ignorable="d" Title="SettingsPage" Background="{StaticResource Settings_Background}" Foreground="White">
    
	<Page.Resources>
        
        <yaTDL_Core_Converters:MultiBoolConverter x:Key="boolConverter" />
		<yaTDL_Core_Converters:IntStringConverter x:Key="intStringConverter"/>
		<yaTDL:IntervalSelectionConverter x:Key="intervalConverter"/>
		<yaTDL_Core_Converters:InverseBooleanConverter x:Key="boolInverter" />
        
	</Page.Resources>

	<Grid MinWidth="589" MinHeight="386">
        
		<TabControl x:Name="tabControl" Margin="110,50,0,47" Style="{DynamicResource HeaderlessTabControl}" FontFamily="Segoe UI">
            
			<TabItem Header="ABOUT" IsSelected="True">
				<Border BorderThickness="0" Margin="0,0,-5,0">
				<FlowDocumentScrollViewer Padding="0" UseLayoutRounding="False" VerticalScrollBarVisibility="Auto" >
                        <FlowDocument PagePadding="0,0,10,0" Foreground="{StaticResource Settings_Foreground}">                        	
                    <Paragraph FontSize="12" TextAlignment="Left" FontFamily="Segoe UI">  
                        <Paragraph.Inlines >     							
                        	<Run FontWeight="Bold" Text="{Binding ApplicationVersion, Mode=OneWay, StringFormat='Version {0}'}"/>
							<LineBreak />
							<LineBreak />
                            <Run>This program has been licensed under the New BSD License (BSD).</Run>
                            <LineBreak />
                            <Hyperlink  Command="{Binding OpenHyperlinkCommand}" CommandParameter="http://yatdl.codeplex.com/">Visit yaTDL Website</Hyperlink>
                        </Paragraph.Inlines>                        
                    </Paragraph>
                    
                    <Paragraph FontSize="12" FontFamily="Segoe UI" FontWeight="Bold">Credits</Paragraph>
                    <List FontSize="12" TextAlignment="Left" FontFamily="Segoe UI">                        
                        <ListItem>
                                    <Paragraph>This software contains portions of code from the "Amuse"-Project Copyright (c) 2009, Nidonocu and other Contributors, which has been licensed under the New BSD License (BSD).                                
                                <Hyperlink Command="{Binding OpenHyperlinkCommand}" CommandParameter="http://amuse.codeplex.com">more Information</Hyperlink>
                            </Paragraph>
                        </ListItem>
                        <ListItem>
                            <Paragraph>yaTDL uses the Simple Logging Façade (SLF) Framework, which has been licensed under the Microsoft Public License (Ms-PL)
                                <Hyperlink  Command="{Binding OpenHyperlinkCommand}" CommandParameter="http://slf.codeplex.com/">more Information</Hyperlink>
                            </Paragraph>    
                        </ListItem>
                        <ListItem>
                            <Paragraph>yaTDL uses the NLog Framework Copyright (c) 2004-2010 Jaroslaw Kowalski, which is distributed under the terms of the BSD license. 
                                <Hyperlink  Command="{Binding OpenHyperlinkCommand}" CommandParameter="http://nlog-project.org/">more Information</Hyperlink>
                            </Paragraph>
                        </ListItem>
                    </List>
                                                   
                </FlowDocument>
				</FlowDocumentScrollViewer>
				</Border>
			</TabItem>
			<TabItem Header="BACKUP" Foreground="White">
				<Grid>
                    <CheckBox x:Name="Checkbox_Backup_Enable" Foreground="{StaticResource Settings_Foreground}" Content="Enable Backups" Margin="6,9,0,0" HorizontalAlignment="Left" Width="112" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Height="16" VerticalAlignment="Top" IsChecked="{Binding Path=Settings.Backup_Enable}"/>
                    <Label Content="Keep" Foreground="{StaticResource Settings_Foreground}" Margin="51,75,0,0" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Padding="5,0,5,0" VerticalAlignment="Top" HorizontalAlignment="Left" Height="23.02" Width="40" x:Name="label1">
						<Label.IsEnabled>
							<MultiBinding FallbackValue="False" Converter="{StaticResource ResourceKey=boolConverter}">
								<Binding ElementName="radioButton_Backup_deleteOldBackups" Path="IsChecked"/>
								<Binding ElementName="Checkbox_Backup_Enable" Path="IsChecked"/>
							</MultiBinding>
						</Label.IsEnabled>
					</Label>
                    <yaTDL_Controls:NumericTextBox IsEnabled="{Binding IsEnabled, ElementName=label1}" Text="{Binding Path=Settings.Backup_Count, Converter={StaticResource intStringConverter}, Mode=TwoWay}" x:Name="Textbox_Backup_Count" Margin="93,75,0,0" TextWrapping="Wrap" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" MaxLines="1" d:LayoutOverrides="VerticalAlignment" HorizontalAlignment="Left" Width="64" Height="23.04" VerticalAlignment="Top" />
                    <Label Foreground="{StaticResource Settings_Foreground}" IsEnabled="{Binding IsEnabled, ElementName=label1}" Height="23.02" HorizontalContentAlignment="Left" Margin="172,75.02,0,0" Padding="5,0" VerticalAlignment="Top" VerticalContentAlignment="Center" HorizontalAlignment="Left" Width="61" x:Name="label2" Content="Backups"/>
                    <Label Foreground="{StaticResource Settings_Foreground}" IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" Height="23.02" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Margin="8,141.02,0,0" Padding="5,0" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="99" Content="Save Backups to"/>
                    <TextBox Foreground="{StaticResource Settings_Foreground}" IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" Height="23.02" HorizontalContentAlignment="Left" Margin="113,141.02,100,0" MaxLines="1" x:Name="textBox_Backup_BackupDirectory" Text="{Binding Path=Settings.Backup_BackupDirectory, Mode=TwoWay}" TextWrapping="NoWrap" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="Auto" />
					<Button IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" Height="23" HorizontalAlignment="Right" Margin="0,141,19,0" x:Name="button_browseFolders" VerticalAlignment="Top" Width="75" Content="Browse" Click="button_browseFolders_Click" />
                    <Label Foreground="{StaticResource Settings_Foreground}" IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Margin="8,112,0,0" Padding="5,0" VerticalContentAlignment="Center" Width="99" Height="23.04" VerticalAlignment="Top" Content="Create a Backup"/>
                    <ComboBox IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" HorizontalAlignment="Left" Margin="113,112.54,0,0" x:Name="comboBox_Backup_Interval" Width="120" SelectedIndex="{Binding Path=Settings.Backup_Interval, Converter={StaticResource intervalConverter}, Mode=TwoWay}" Height="23.04" VerticalAlignment="Top" VerticalContentAlignment="Center">
						<ComboBoxItem x:Name="comboboxItem_hourly" Content="Hourly"/>
						<ComboBoxItem x:Name="comboboxItem_daily" Content="Daily"/>
						<ComboBoxItem x:Name="comboboxItem_weekly" Content="Weekly"/>
					</ComboBox>
                    <RadioButton Foreground="{StaticResource Settings_Foreground}" IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" IsChecked="{Binding Path=Settings.Backup_KeepAll, Mode=TwoWay}" Height="16" HorizontalAlignment="Left" Margin="32,31,0,0" x:Name="radioButton_Backup_keepAll" VerticalAlignment="Top" Width="120" Content="Keep all Backups"/>
                    <RadioButton Foreground="{StaticResource Settings_Foreground}" IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" IsChecked="{Binding IsChecked, Converter={StaticResource boolInverter}, ElementName=radioButton_Backup_keepAll}" Height="16" HorizontalAlignment="Left" Margin="32,53,0,0" x:Name="radioButton_Backup_deleteOldBackups" VerticalAlignment="Top" Width="120" Content="Delete Old Backups"/>
                    <Label Foreground="{StaticResource Settings_Foreground}" IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" Content="{Binding Path=Settings.Backup_LastBackup}"
						Height="23.04" HorizontalContentAlignment="Left" Margin="113,169.04,0,0" Padding="5,0" VerticalAlignment="Top" 
						VerticalContentAlignment="Center" HorizontalAlignment="Left" Width="140"/>
                    <Label Foreground="{StaticResource Settings_Foreground}" Content="Last Backup:" Height="23.04" HorizontalAlignment="Left" IsEnabled="{Binding IsChecked, ElementName=Checkbox_Backup_Enable}" Margin="8,169.04,0,0" Padding="5,0" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="99" d:LayoutOverrides="HorizontalAlignment" />
                    <Button Foreground="{StaticResource Settings_Foreground}" Content="Backup now" HorizontalAlignment="Left" Margin="113,195.04,0,0" VerticalAlignment="Top" Width="120" Height="23" Command="{Binding CreateBackupCommand}"/>
				</Grid>
			</TabItem>
			<TabItem Header="SYNC" Foreground="White">
				<Grid>
                    <CheckBox Foreground="{StaticResource Settings_Foreground}" Content="Enable Syncing " IsChecked="{Binding Path=Settings.Toodledo_EnableSync, Mode=TwoWay}" Height="16" HorizontalAlignment="Left" Margin="14,14,0,0" x:Name="checkBox_EnableSyncing" VerticalAlignment="Top" />                    
					<Button IsEnabled="{Binding IsChecked, ElementName=checkBox_EnableSyncing}" Content="{Binding EditAccountButtonText}" Height="23" HorizontalAlignment="Left" Margin="39,91,0,0" x:Name="button_editCredentials" VerticalAlignment="Top" Width="115" Command="{Binding EditAccountCommand}" />
                    <TextBlock Foreground="{StaticResource Settings_Foreground}" Height="49" Margin="39,36,8,0" x:Name="textBlock_Account" Text="{Binding AccountInfoText}" IsEnabled="{Binding IsChecked, ElementName=checkBox_EnableSyncing}" VerticalAlignment="Top" />
                    <Button Content="Delete Account" Height="23" IsEnabled="{Binding IsChecked, ElementName=checkBox_EnableSyncing}" Margin="158,91,0,0" VerticalAlignment="Top" Command="{Binding DeleteAccountCommand}" d:LayoutOverrides="VerticalAlignment" HorizontalAlignment="Left" Width="115" />
                    <Label Foreground="{StaticResource Settings_Foreground}" Content="{Binding Path=Settings.Toodledo_LastSync, Mode=OneWay}" HorizontalAlignment="Left" Margin="39,135,0,114.04" ContentStringFormat="Last Sync: {0}" d:LayoutOverrides="Height"/>
                    <Button Content="Sync now" HorizontalAlignment="Left" Margin="39,179,0,0" VerticalAlignment="Top" Width="115" Command="{Binding StartSyncCommand}"/>
                    <Button Content="Reset Sync Data" HorizontalAlignment="Left" Height="23" Margin="158,179,0,0" VerticalAlignment="Top"  Width="115" Command="{Binding ResetSyncDataCommand}"/>
				</Grid>
			</TabItem>
		</TabControl>
        
        <ListBox HorizontalAlignment="Left" ItemContainerStyle="{StaticResource ListBoxItemStyle_SettingsSelector}" FontSize="12" FontFamily="Segoe WP" ItemsSource="{Binding Items, ElementName=tabControl}" 
                 SelectedItem="{Binding SelectedItem, ElementName=tabControl, Mode=TwoWay}" Margin="8,50,0,47" Width="90"
                 BorderBrush="{StaticResource Application_BorderBrush}" BorderThickness="0,0,1,0" Background="{x:Null}">
			<ListBox.ItemTemplate>
				<DataTemplate>
					<TextBlock  Text="{Binding Header}"/>    		
				</DataTemplate>     	
			</ListBox.ItemTemplate>      
		</ListBox>
        
		<Button Content="OK" Height="20" FontSize="10" HorizontalAlignment="Right" Margin="0,0,91,12" Command="{Binding OkCommand}" VerticalAlignment="Bottom" Width="75" />
        <Button Content="CANCEL" Height="20" FontSize="10" HorizontalAlignment="Right" Margin="0,0,12,12" Command="{Binding CancelCommand}" VerticalAlignment="Bottom" Width="75" />
        <Label Foreground="{StaticResource Settings_Foreground}" Content="settings" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="20" FontFamily="Segoe UI" FontWeight="Bold" Margin="4,-1,0,0"/>
	</Grid>
</Page>
